<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>编辑玩法攻略管理</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript"  charset="utf-8" src="/dingdingbox/assets/scripts/ueditor/ueditor.config.js"></script>
		<script type="text/javascript"  charset="utf-8"  src="/dingdingbox/assets/scripts/ueditor/ueditor.all.js"></script>				
		<script type="text/javascript">
			$(function() {
				//初始化表单验证
				$("#inputForm").initValidform();
				
				 var options = {
			        		initialFrameWidth:800,
			        		initialFrameHeight:300,
			        		focus:false,
		        };
				    
			    //初始化上传控件
			    $(".upload-img").InitUploader({ type:'gameStrategy', filesize: "", sendurl: "${ctx}/db/upload", swf: "${ctxStatic}/scripts/webuploader/uploader.swf", filetypes: "" });
				 		 
				var ueditor = new UE.ui.Editor(options);
				ueditor.render("text");
				
				//初始化编辑器
		        var editor = KindEditor.create('.editor', {
		            width: '100%',
		            height: '350px',
		            resizeType: 1,
		            uploadJson: '${ctx}/sb/upload?action=EditorFile&IsWater=1&Type=',
		            fileManagerJson: '${ctx}/sb/upload?action=ManagerFile',
		            allowFileManager: true
		        });
		        var editorMini = KindEditor.create('.editor-mini', {
		            width: '100%',
		            height: '250px',
		            resizeType: 1,
		            uploadJson: '${ctx}/sb/upload?action=EditorFile&IsWater=1&type=',
		            items: [
						'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		        });								
			});
			
			//添加图片相册
			function addImage(targetObj, data) {
				targetObj.siblings(".upload-name").val(data.name);
				targetObj.siblings(".upload-path").val(data.path);
				targetObj.siblings(".upload-size").val(data.size);
				
			    //插入到相册UL里面
			    var newLi = $('<li>'
			    + '<input type="hidden" name="hid_photo_name" value="'+ data.type + '|' + data.name + '|' + data.path + '|' + data.thumb + '|' + data.size + '|' + data.ext + '" />'
			    + '<input type="hidden" name="hid_photo_remark" value="" />'
			    + '<div class="img-box" onclick="setFocusImg(this);">'
			    + '<img src="${root}/cdn/image/' + data.thumb + '" bigsrc="${root}/cdn/image/' + data.path + '" />'
			    + '<span class="remark"><i>暂无描述...</i></span>'
			    + '</div>'
			    + '<a href="javascript:;" onclick="setRemark(this);">描述</a>'
			    + '<a href="javascript:;" onclick="delImg(this);">删除</a>'
			    + '</li>');
			    newLi.appendTo(targetObj.siblings(".photo-list").children("ul"));

			    //默认第一个为相册封面
			    var focusPhotoObj = targetObj.siblings(".focus-photo");
			    if (focusPhotoObj.val() == "") {
			        focusPhotoObj.val(thumbSrc);
			        newLi.children(".img-box").addClass("selected");
			    }
			    
			} 			
			
		</script>
	</head>
	
	<body class="mainbody">
		<form:form id="inputForm" modelAttribute="gameStrategy" action="${ctx}/db/gameStrategy/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<!--导航栏-->
			<div class="location">
				<a href="${ctx}/db/gameStrategy/list" class="back"><i></i><span>返回列表页</span></a>
				<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> 
				<i class="arrow"></i> 
				<a href="${ctx}/db/gameStrategy/form?id=${gameStrategy.id}"><span>玩法攻略管理</span></a>
				<shiro:hasPermission name="db:gameStrategy:edit"><i class="arrow"></i><span>${not empty gameStrategy.id ? '修改':'添加' }玩法攻略管理</span></shiro:hasPermission>
			</div>	
			<div class="line10"></div>
			<!--/导航栏-->
	
			<!--内容-->
			<div id="floatHead" class="content-tab-wrap">
				<div class="content-tab">
					<div class="content-tab-ul-wrap">
						<ul>
							<li><a class="selected" href="javascript:;">玩法攻略管理信息</a></li>
						</ul>
					</div>
				</div>
			</div>
	
			<div class="tab-content">
				<dl>
					<dt>玩具盒</dt>			
					<dd>
						<div class="rule-single-select single-select" >
							<form:select id="selectOption"  path="boxId" errormsg="请输入选择节点" sucmsg=" ">
							<c:choose>
							   <c:when test="${boxList==null}">  
								   <form:option value="0"  label="暂无类型"></form:option>
							   </c:when>
							   <c:otherwise> 
						    	  <form:options items="${boxList}" itemLabel="name" itemValue="id"/>
							   </c:otherwise>
							</c:choose>	
							</form:select>
						</div>
						<span class="Validform_checktip"></span>				
					</dd>															
				</dl>
				
				<dl>
					<dt>封面</dt>
					<dd>
						<div class="upload-box upload-img"></div>
						<div class="photo-list">
							<ul>
								<c:forEach items="${gameStrategyAlbum }" var="ca">
	                        	<li>
	                        		<input type="hidden" name="hid_photo_name" value="${ca.category }|${ca.fileName }|${ca.orginPath }|${ca.thumbPath }|${ca.albumSize }|jpg">
	                        		<input type="hidden" name="hid_photo_remark" value="${ca.remarks }">
	                        		<div class="img-box" onclick="setFocusImg(this);">
	                        			<img src="${root}/cdn/image/${ca.thumbPath }" bigsrc="${root}/cdn/image/${ca.orginPath }">
	                        			<span class="remark"><i>${empty ca.remarks ? '暂无描述...': ca.remarks}</i></span>
	                        		</div>
	                        		<a href="javascript:;" onclick="setRemark(this);">描述</a>
	                        		<a href="javascript:;" onclick="delImg(this);">删除</a>
	                       		</li>
	                        	</c:forEach>
							</ul>
						</div>
					</dd>
				</dl>						
				
				<dl>
					<dt>标题</dt>
					<dd>
						<form:input path="title" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入标题" errormsg="请输入标题" sucmsg=" "/>
						<span class="Validform_checktip">*请输入标题</span>
					</dd>
				</dl>
				
				<dl>
					<dt>作者</dt>
					<dd>
						<form:input path="author" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" />
						<span class="Validform_checktip">*请输入作者</span>
					</dd>
				</dl>
				
				<dl>
					<dt>摘要</dt>
					<dd>
						<form:input path="summary" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" />
						<span class="Validform_checktip">*请输入摘要</span>
					</dd>
				</dl>								
				<dl>					
					<dt>推荐</dt>	
					<dd>
							<div class="rule-multi-radio">
							    <form:radiobutton path="isRecommended"  value="0"  label="否" checked="checked" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请选择是否推荐" errormsg="请选择是否推荐" sucmsg=" "/>
							    <form:radiobutton path="isRecommended"  value="1"  label="是" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请选择是否推荐" errormsg="请选择是否推荐" sucmsg=" "/>
							</div>
					</dd>					
				</dl>

				<dl>
					<dt>内容</dt>
					<dd>
						<form:textarea id="text" path="text" htmlEscape="false"  class="required"  datatype="*" nullmsg="请输入详细内容" errormsg="请输入详细内容" sucmsg=" "/>
					</dd>
				</dl>				
			</div>
			<!--/内容-->
	
			<!--工具栏-->
			<div class="page-footer">
				<div class="btn-wrap">
					<input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn" /> 
					<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
				</div>
			</div>
			<!--/工具栏-->
		</form:form>
	</body>
</html>

